package com.llt.product.controller;


import com.llt.product.api.ProductInterface;
import com.llt.product.model.ProductDetail;
import com.llt.product.service.IProductDetailService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;

import org.springframework.web.bind.annotation.RestController;

/**
 * <p>
 * 产品表 前端控制器
 * </p>
 *
 * @author llt
 * @since 2024-05-10
 */
@RestController
@RequestMapping("/product")
public class ProductDetailController implements ProductInterface {

    @Autowired
    private IProductDetailService productDetailService;

    // 根据 id 获取产品
    @RequestMapping("/{productId}")
    public ProductDetail getProductInfo(@PathVariable("productId") Integer productId) {
        return productDetailService.getById(productId);
    }

    @RequestMapping("/p1")
    public String p1(Integer id){
        return "product-service 接收到参数, id:"+id;
    }

    @RequestMapping("/p2")
    public String p2(Integer id, String name){
        return "product-service 接收到参数, id:"+id+",name:"+name;
    }

    @RequestMapping("/p3")
    public String p3(ProductDetail productInfo){
        return "product-service 接收到参数: productInfo"+productInfo.toString();
    }

    @RequestMapping("/p4")
    public String p4(@RequestBody ProductDetail productInfo){
        return "product-service 接收到参数: productInfo"+productInfo.toString();
    }


}
